package com.qiya.LiaoDa.kb;


import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.qiya.LiaoDa.R;

import java.util.List;

public class SearchActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btn_return;
    private ListView lv_searchlist;
    private TextView tv_searchText;
    private TextView tv_searchSum;
    DBOperate dbOperate=new DBOperate();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);
        lv_searchlist=(ListView)findViewById(R.id.lv_searchlist);
        tv_searchText=(TextView)findViewById(R.id.tv_searchText);
        tv_searchSum=(TextView)findViewById(R.id.tv_searchSum);
        btn_return=(Button)findViewById(R.id.btn_return);
        btn_return.setOnClickListener(this);
        dbOperate.test(this);
        Bundle bundle=getIntent().getExtras();
        String searchKey=bundle.getString("searchKey");
        List<SP> searchList=dbOperate.searchByAll(searchKey);
        tv_searchText.setText(searchKey);
        tv_searchSum.setText(String.valueOf(searchList.size()+"条信息"));
        if (!searchList.isEmpty()){
            MyAdapter myAdapter=new MyAdapter(searchList,this);
            lv_searchlist.setAdapter(myAdapter);
        }
    }
    @Override
    public void onClick(View v) {
       finish();
    }
}